wayland: Compare serial numbers correctly to avoid overflow problems
authorKristian Høgsberg <krh@bitplanet.net>
Sat, 24 Aug 2013 06:08:13 +0000 (23:08 -0700)
committerKristian Høgsberg <krh@bitplanet.net>
Sat, 24 Aug 2013 06:15:53 +0000 (23:15 -0700)
We have to look at the difference between two numbers, which will always
be well-defined and give the right result, even in case of integer overflow.

gdk/wayland/gdkdisplay-wayland.c

index db47bfe0ccb1194379e1e63a0cc64d23f66cd5f5..e9424b208cdc3093c275515fff5ecd6e7eb4dcdf 100644 (file)
@@ -678,8 +678,12 @@ void
 _gdk_wayland_display_update_serial (GdkWaylandDisplay *wayland_display,
                                     guint32            serial)
 {
-  if (serial > wayland_display->serial)
+  if (serial - wayland_display->serial < 1000)
     wayland_display->serial = serial;
+  else
+    g_warning (G_STRLOC ": serial number jump bigger than 1000 (%u -> %u",
+               wayland_display->serial, serial);
+
 }
 
 /**